package com.link2room.bumblebee.redisQueueHandler;

import com.link2room.common.enums.BaseSysExceptionEnum;
import com.link2room.common.exception.SysException;
import com.link2room.common.mnsLog.RedisMsgHandler;
import com.link2room.common.mnsLog.model.ProducteMnsQueue;
import com.link2room.common.util.JacksonUtil;
import com.link2room.bumblebee.dto.param.MnsProducterLogParamDto;
import com.link2room.bumblebee.facade.ImnsLogFacadeService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by LN on 2017/9/12.9:56
 */
@Component("mnsProducterLogQueueHandler")
public class MnsProducterLogQueueHandler implements RedisMsgHandler {
    @Resource
    private ImnsLogFacadeService mnsLogFacadeService;
    @Override
    public boolean handle(String msg) {

        MnsProducterLogParamDto paramDto = new MnsProducterLogParamDto();
        paramDto.setProducteMnsQueue(JacksonUtil.jsonToBean(msg, ProducteMnsQueue.class));
        try {
            mnsLogFacadeService.logProducter(paramDto);
        } catch (Exception e) {
            throw new SysException(BaseSysExceptionEnum.BASE_FUCATION_OPTION,e);
        }
        return false;
    }
}
